import { Condition } from "/@/Configuration/ConditionPanel/types";

export const SvgWidth = 3000;
export const SvgHeight = 3000;
export const GridShares = 20;
export const TextFontSzie = 14;
export const ValueColor = "#172B4D";
export const UnitColor = "#7B879A";
export const LabelColor = "#7B879A";
export const OperSize = 10;
export const FlowPathOperSize = 12;
export const IconSize = 16;
export const FlowPathLegendSize = {
  width: 32,
  height: 32,
};
export const PipePathColors = ["#333333", "#000000"];

/**
 * 获取所有在触发范围的条件
 * @param conditionData 组件已设置的条件数据
 * @param data 外界数据
 * @returns 所有在触发范围的条件
 */
export function getApplyCondition(conditionData: Condition[], data: Record<string, any>) {
  const applyCondition: Condition[] = [];
  conditionData.forEach((condition) => {
    const value = data[condition.dataKey];
    if (value !== undefined) {
      if ((condition.min !== null && value < condition.min) || (condition.max !== null && value > condition.max)) {
        return;
      }
      applyCondition.push(condition);
    }
  });
  return applyCondition;
}
